<template>
	<view class="inform">
	
		<!-- <text class="defaultText" v-if="!groupList.length > 0">暂时没有新的通知</text>
	
		<view v-for="item in groupList" :key="item.from" class="itemBar">
	
			<view class="notInfoDetContent">
				<view class="headContent">
					<image src='/static/images/theme@2x.png'></image>
				</view>
				<view class="infoContent">
					<text class="itemName">{{ item.from }}</text>
					<text>邀请您加入群组为{{item.roomid}}</text>
				</view>
			</view>
			
			<view class="buttonContent">
			
				<view class="actionDone">已同意</view>
			</view>
	
		</view> -->
		
		<text class="defaultText" v-if="!groupListShare.length > 0">暂时没有新的通知</text>
			
		<view v-for="item in groupListShare" :key="item.from" class="itemBar">
			
			<view v-if="item.share_user.name||item.share_user.nickName" class='has_width'>
			<view class="notInfoDetContent" >
				<view class="headContent">
					<image :src='item.share_user.avatarUrl||"/static/images/theme@2x.png"'></image>
				</view>
				<view class="infoContent" >
					<text class="itemName">{{ item.user.name||item.user.nickName }}</text>
					<text>邀请您加入群组为{{item.hxGroups.groupname}}</text>
				</view>
				<view class="buttonContent">
				
					<view class="actionDone" v-if="item.is_agree==0">申请中</view>
					<view class="actionDone" v-else-if="item.is_agree==1">已同意</view>
				</view>
			</view>
			</view>
			
			
			
			<view v-else class='has_width'>
				<view class="notInfoDetContent" >
					<view class="headContent">
						<image src='/static/images/theme@2x.png'></image>
					</view>
					<view class="infoContent" >
						<text class="itemName">系统管理员</text>
						<text>邀请您加入群组为{{item.hxGroups.groupname}}</text>
					</view>
				</view>
				<view class="buttonContent">
				
					<view class="actionDone" v-if="item.is_agree==0">申请中</view>
					<view class="actionDone" v-else-if="item.is_agree==1">已同意</view>
				</view>
			</view>
			
			
			
		</view>
	</view>
</template>

<script>
	// let disp = require("../../utils/broadcast");
	import {
		GYZJMODEL as gyzjModel
	} from '@/utils/gyzjModel.js'; 
	export default {
		data() {
			return {
				groupList: [],
				groupListShare:[],
				page:1,
				limit:10,
			}
		},
		onLoad() {
			var me = this;
			// 不需要 object 地址更新，就能刷
			// disp.on("em.xmpp.invite.joingroup", function(){
			// 	me.groupList = getApp().globalData.saveGroupInvitedList
			// 	uni.setStorageSync("groupNotiData", getApp().globalData.saveGroupInvitedList)
			// });
			
			// this.groupList = uni.getStorageSync("groupNotiData")
			
			this.listGroupsAllShare();
		},
		onShow(){
			// getApp().globalData.saveGroupInvitedList = [];
			// this.listGroups()
		},
		methods: {
			/*所有的群*/
			listGroupsAllShare(){
				var that = this;
				var arr=that.main_getGlobal();
				gyzjModel.prototype.listGroupsAllShare(arr.token, arr.type).then(data=>{
					that.groupListShare=data.data.data;
					that.page=data.data.page_count;
					that.limit=data.data.total_count;
				})
			},
			listGroups(){
				var me = this;
				return me.$im.conn.listRooms({
					success: function(rooms){
						uni.setStorage({
							key: "listGroup",
							data: rooms
						});
					},
					error: function(err){ 
						console.log(err)
					}
				});
			},
			
			removeAndRefresh(removeId){
				
			},
		}
	}
</script>

<style>
	/*设置百分比宽度*/
	.has_width{
		width:100%;
	}
	/*设置百分比宽度*/
page{
	background-color: #FAFAFA;
}
.defaultText{
	color: #E3E3E3;
	font-size: 32rpx;
	text-align: center;
	display: block;
	margin: 300rpx auto 0 auto;
}
.itemBar{
	margin: 20rpx 40rpx;
	min-height: 252rpx;
	background-color: #fff;
	border: 1px solid #FAFAFA;
	border-radius: 10rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
}
.notInfoDetContent{
	min-height: 160rpx;
	width: 100%;
	border-bottom: 1px solid #FAFAFA;
}
.headContent{
	width: 72rpx;
	height: 72rpx;
	border-radius: 50%;
	margin: 24rpx 30rpx 0;
	float: left;
}
.headContent image{
	width: 72rpx;
	height: 72rpx;
}
.infoContent{
	display: flex;
	flex-direction: column;
}
.infoContent text{
	min-height: 54rpx;
	line-height: 54rpx;
	font-size: 28rpx;
	color: #9B9B9B;
}
.infoContent .itemName{
	height: 62rpx;
	font-size: 32rpx;
	line-height: 62rpx;
	color: #000;
	margin-top: 24rpx;
	overflow: hidden;
	text-overflow: ellipsis;
}

.buttonContent{
	display: inline-flex;
	width: 100%;
	flex: 1;
	height: 72rpx;
}
.buttonContent .agreeBtn, .buttonContent .rejectBtn{
	flex: 1;
	font-size: 32rpx;
	background-color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
}
.agreeBtn{
	color: #0873DE;
}
.rejectBtn{
	color: #666666;
}
.centerLine{
	border-right: 1px solid #FAFAFA;
}
.actionDone{
	flex: 1;
	font-size: 32rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #999999;
}

</style>


